<template>
  <div id="system-box">
    <el-header>阿里妈妈车位租赁管理系统</el-header>
    <div class="all">
      <div class="green-border">
        <h3>超级管理员登录</h3>
        <br />
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="用户名:">
            <el-input v-model="form.username"></el-input>
          </el-form-item>
          <el-form-item label="密 码:">
            <el-input v-model="form.password" type="password"></el-input>
          </el-form-item>
          <el-form-item id="login-box">
            <el-button type="success" @click="login()">立即登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>

    <el-footer></el-footer>
  </div>
</template>

<script>
import apis from "../../http/apis/apis";

export default {
  data() {
    return {
      form: {
        username: "",
        password: "",
      },
    };
  },

  methods: {
    async login() {
      const data = await apis.adminsApi.SuperAdminslogin({ ...this.form });
      console.log("页面", data);
      if (data.data.status) {
        localStorage.token = data.data.token;
        localStorage.username = data.data.data[0].username;
        localStorage._id = data.data.data[0]._id;
        this.$router.push("/superAdminsSystem");
      } else {
        alert("登录失败");
      }
    },
  },
};
</script>

<style scoped  lang='scss'>
#system-box {
  height: 100vh;
  display: flex;
  flex-direction: column;

  .el-header {
    height: 50px;
    background: lightgreen;
    line-height: 50px;
    font-size: 30px;
    font-weight: bolder;
  }
  .all {
    flex: 1;
    .green-border {
      border: rgb(20, 197, 20) 2px solid;
      height: 350px;
      width: 500px;
      padding: 60px 50px;
      margin: 70px auto;
      border-radius: 20px;
      #login-box {
        text-align: center;
        margin-left: -80px;
      }
    }
  }
  .el-footer {
    height: 50px;
    background: lightgreen;
  }
}
</style>